const cronplus = msg?.cronplus;
const config = cronplus?.config;
const configPayload = config?.payload;

if (cronplus && config && configPayload) {
    // console.log('msg.cronplus:', cronplus)
    // node.warn("msg.cronplus:"+JSON.stringify(cronplus));

    const propId = configPayload?.propId
    const setVal = configPayload?.setVal

    // Handle multiple propIds (comma-separated)
    if (typeof propId === 'string' && propId.includes(',')) {
        // Multiple propIds case - create array for split node
        const propIds = propId.split(',').map(id => id.trim()).filter(id => id);
        
        // Create array of individual messages for split node
        const messagesArray = propIds.map(id => ({
            content: { [id]: setVal }
        }));
        
        msg.payload = messagesArray;
        
        console.log('Processing multiple propIds:', propIds);
        console.log('Created array with', messagesArray.length, 'items for split node');
        
    } else {
        // Single propId case - maintain original behavior
        const payload = [{ "content": { [propId]: setVal } }]
        msg.payload = payload;
        console.log('Processing single propId:', propId);
        console.log('Generated payload:', JSON.stringify(payload, null, 2));
    }
}
else {
    console.log('msg.cronplus not object:')
    return null
    
}


return msg;